<template>
  <div class="test">
    <button @click="handleClick">点击获取三级分类信息</button>
    <h2>读取home中的state---$store------name:{{$store.state.user.name}}</h2>
    <h2>读取home中的state---mapstate----name:{{name}}</h2>
  </div>
</template>

<script>
import { reqCategory } from "@/api";
import { mapState } from 'vuex';
export default {
  name: "Test",
  computed:{
...mapState({
  name:state=>{
    console.log(state)
    return state.user.name}
})
  },
  methods: {
    async handleClick() {
      //函数使用
      let res = await reqCategory();
      console.log(res);
    },
  },
};
</script>

<style lang="less" scoped>
.test {
  background-color: palegoldenrod;
}
</style>